package com.example.DataSource.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.DataSource.Mapper.CMMapper;
import com.example.DataSource.entity.ChatMessage;
import com.example.DataSource.serviceImpl.CMServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/ljkDemo/CM") // CM: 咨询回复管理
public class CMController {
    @Autowired
    private CMMapper cmMapper;
    @Autowired
    private CMServiceImpl cmService;

    @GetMapping("/getAll")
    public IPage<ChatMessage> getAll(int current, int size) {
        Page<ChatMessage> page = new Page<>(current, size);
        return cmService.getCMPage(page);
    }

    @GetMapping("/search")
    public IPage<ChatMessage> search(int current, int size, String searchInfo) {
        Page<ChatMessage> page = new Page<>(current, size);
        return cmService.getCMPageSearch(page, searchInfo);
    }

    @GetMapping("/deleteInfo")
    public void delete(String id) {
        cmService.removeById(id);
    }

    @PostMapping("/reply")
    public void reply(
            @RequestParam("targetContent") String targetContent,
            @RequestParam("targetTime") String targetTime,
            @RequestParam("replyContent") String replyContent
    ) {
//        vipId: 提问者，但是这里逻辑有问题，只能查询会员
//        consultantID: 回复者，但是这里逻辑有问题，只能查询咨询师

        System.out.println(targetContent);
        System.out.println(replyContent);
    }
}
